package com.xy.lang.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public enum HandOverResultEnum implements CodeEnum {

    UNDO(0, "待交付", "undo", "undo"),
    TO_WAREHOUSE(1, "直接入库", "入库", "receiver_warehouse"),
    TO_CHECK(2, "通知质检", "质检", "receiver_inspection"),
    TO_SPLIT(4, "通知分装", "分装", "receiver_split"),
    TO_NEW_COA(5, "生成COA", "COA", "generate_coa"),
    TO_REPLACE_COA(6, "替换COA", "COA", "replace_coa");

    private int code;
    private String name;
    private String handOverName;
    private String dictCode;

    HandOverResultEnum(int code, String name, String handOverName, String dictCode) {
        this.code = code;
        this.name = name;
        this.handOverName = handOverName;
        this.dictCode = dictCode;
    }

    @Override
    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDictCode() {
        return dictCode;
    }

    public String getHandOverName() {
        return handOverName;
    }

    public static String getDictCode(int code) {
        HandOverResultEnum[] values = HandOverResultEnum.values();
        Map<Integer, String> bizTypeMap =
                Arrays.stream(values)
                        .collect(Collectors.toMap(HandOverResultEnum::getCode, HandOverResultEnum::getDictCode));
        if (bizTypeMap.containsKey(code)) {
            return bizTypeMap.get(code);
        }
        return null;
    }

    public static String getHandOverName(int code) {
        HandOverResultEnum[] values = HandOverResultEnum.values();
        Map<Integer, String> bizTypeMap =
                Arrays.stream(values)
                        .collect(Collectors.toMap(HandOverResultEnum::getCode, HandOverResultEnum::getHandOverName));
        if (bizTypeMap.containsKey(code)) {
            return bizTypeMap.get(code);
        }
        return null;
    }
}
